package com.dc.designPattern._0_设计原则._2_ocp.step1;

/**
 * Description: 绘图类 [使用方]
 * @author: gdc
 * @date: 2021/7/23
 * @version 1.0
 */
public class GraphicEditor {

    /**
     * 接收 Shape 对象，然后根据 type，来绘制不同的图形
     * @param s
     */
    public void drawShape(Shape s) {
        if (s.type == 1) {
            drawRectangle(s);
        } else if (s.type == 2) {
            drawCircle(s);
        } else if (s.type == 3) {
            drawTriangle(s);
        }
    }

    /**
     * 绘制矩形
     */
    public void drawRectangle(Shape r) {
        System.out.println(" 绘制矩形 ");
    }

    /**
     * 绘制圆形
     */
    public void drawCircle(Shape r) {
        System.out.println(" 绘制圆形 ");
    }

    /**
     * 绘制三角形
     */
    public void drawTriangle(Shape r) {
        System.out.println(" 绘制三角形 ");
    }
}